package com.ego.controller;

import com.ego.dao.DressDao;
import com.ego.dao.impl.DressDaoImpl;
import com.ego.vo.ProductListVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author 袁梦达 2019012364
 */
@WebServlet("/DressDiscountListServlet")
public class DressDiscountListServlet extends HttpServlet {

    private DressDao dressDao = new DressDaoImpl();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        List<ProductListVo> productList = dressDao.getProductDiscountList();
        for (ProductListVo product : productList) {
            String msg = product.getId() + "@" + product.getBaseInformation() + "@" + product.getImage() + "@" + product.getPrice() + "#";
            response.getWriter().print(msg);
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
